
export default {
    // 左侧展开当前菜单
    curNavGroup: state =>{
        let curnav = state.crumbData.curNav,
            navList = state.subNavList || [],
            active_index = '',
            default_opens = [];
        const navListForeach = (list)=>{
            list.forEach((v,i)=>{
                if( v.uri && v.uri===curnav ){
                    active_index = v.index;
                    return ;
                }else if( v.submenu ){
                    navListForeach(v.submenu)
                }
            })
        }
        navListForeach(navList);
        const active_arr = active_index.split('_');
        active_arr.forEach((v,i)=>{
            default_opens.push(active_arr.slice(0,i+1).join('_'));
        });

        return default_opens;
    },
    // 当前导航面包屑
    curCrumbList: (state, getters) =>{
        let crumbList = [],
            curNavGroup = getters.curNavGroup[getters.curNavGroup.length-1] || '';
        let arr = curNavGroup.length>0 ? curNavGroup.split("_") : [],
            curnav = state.crumbData.curNav,
            navList = state.subNavList || [],
            navItem = navList;
        arr.forEach((v,i)=>{
            navItem = navItem[v-1];
            crumbList.push({"text": navItem.text });
            navItem = navItem.submenu;
        });
        return crumbList;
    }
}